package com.example.demo.commen.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * user:likai
 * Date:2023-02-18
 * Time:19:32
 */
//配置信息类
@Configuration
public class AppConfig implements WebMvcConfigurer {

    @Autowired
    private LoginIntercetor loginIntercetor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(loginIntercetor);
        InterceptorRegistration registry1= registry.addInterceptor(loginIntercetor);
        registry1.addPathPatterns("/**");
        registry1.excludePathPatterns("/css/**");
        registry1.excludePathPatterns("/editor.md/**");
        registry1.excludePathPatterns("/img/**");
        registry1.excludePathPatterns("/js/**");
        registry1.excludePathPatterns("/**/*.html");
        registry1.excludePathPatterns("/**/login.html");
        registry1.excludePathPatterns("/**/reg.html");
        registry1.excludePathPatterns("/user/login");
        registry1.excludePathPatterns("/user/reg");
        registry1.excludePathPatterns("/art/detail");//文章详情页w
        registry1.excludePathPatterns("/art/list");
        registry1.excludePathPatterns("/art/totalpage");
    }
}
